var express = require('express')
var path = require('path')
var bodyParser = require('body-parser')
var serveStatic = require('serve-static')
var port = process.env.PORT || 3000
var app = express()



app.set('views', './views/pages')
app.set('view engine', 'jade')
app.use(serveStatic('bower_components'))
app.use(bodyParser.urlencoded({ extended: false }))
app.listen(port);

console.log('imooc started on port ' + port)

// index page

app.get('/', function (req, res) {
    res.render('./index', {
        title: 'imooc 首页',
        movies: [{
            title:'机械战警',
            _id: 1,
            poster: 'http://g2.ykimg.com/05160000530EEB63675839160D0B79D5'
        }]
    })
})

// list page

app.get('/admin/list', function (req, res) {
    res.render('./list', {
        title: 'imooc 列表页',
        movies: [{
            title:'机械战警',
            _id: 1,
            language: 'English'
        }]
    })
})

// detail page

app.get('/movie/:id', function (req, res) {
    res.render('./detail', {
        title: 'imooc 详情页',
        movie: {
            title: '机械战警',
            language: 'English',
            flash: ''
        }
    })
})

// admin page

app.get('/admin/movie',function (req, res) {
    res.render('./admin', {
        title: 'imooc 后台录入',
        movie: {
            title: '',
            language: ''
        }
    })
})